<?php
/**
 * 2020/10/9
 * Created by breeze
 * User: breeze
 */
namespace app\api\validate;

use think\Validate;

class User extends Validate{
    protected $rule = [
        "username" => "require",
        "phone_number" => "require|mobile",
        'code' => "require|number|min:4",
//        'type' => "require|in:1,2",
        'type' => ["require","in"=>"1,2"],
        'sex' => ['require',"in"=>"1,2,0"]
    ];

    protected $message = [
        "username.require" => "用户名必须填",
        "phone_number.mobile" => "必须是手机号",
        "phone_number.require" => "电话号码必须",
        "code.require" => "短信验证码必须",
        "code.number" => "短信验证码必须是数字",
        "code.min" => "短信验证码的长度不低于4",
        "type.require" => "类型必须",
        "type.in" => "类型值错误",
        "sex.require" => "性别不能为空",
        "sex.in" => "性别类型值错误"
    ];
    protected $scene = [
        'send_code' => ['phone_number'],
        'login' => ['phone_number','code','type'],
        "user_update" => ['username','sex']
    ];
}